<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>生产暂停</title>
    <c:import url="../../header.jsp"/>
    <link rel="stylesheet" href="${rootUrl}/static/css/time-status-color.css?v=${version}">
    <style>
        table.crm-table.cell-border tbody td{
            white-space: nowrap;
        }
    </style>
</head>
<body>
<div class="body-main">
    <%--tab标签--%>
    <%--<div class="main-title">--%>
    <%--<span class="bus-state">--%>
    <%--<font>生产暂停</font>--%>
    <%--</span>--%>
    <%--</div>--%>

    <%--搜索条件--%>
    <div class="titleSearch">
        <div class="layui-inline">
            <label>业务类型：</label>
            <div class="layui-input-inline">
                <div id="business_typeCode">
                    <input type="hidden" name="typeCodeId" class="plug-in-msg"/>
                    <input type="hidden" name="typeCode" id="typeCode" class="plug-in-code"/>
                    <input type="text" readonly placeholder="请选择业态" class="chose-plugIn layui-input"
                           name="businessTypeName">
                    <div class="bus-picker">
                        <div class="bus-picker-tab">
                            <a href="javascript:void(0);" class="active">请选择业态</a>
                        </div>
                        <div class="bus-picker-content"></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-inline">
            <label>当前已完成节点：</label>

            <div class="layui-inline">
                <select class="select-style " name="latestEndNodeName" id="latestEndNodeName">
                    <option value>请选择</option>
                    <c:forEach var="listNode" items="${listNode}">
                        <option value="${listNode.name}">${listNode.name}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label>流程人员：</label>
            <div class="layui-input-inline select2-inline">
                <select class="select-style" name="flowUserId" divisionUser-select-law>
                    <option value>请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label>客户电话：</label>
            <div class="layui-input-inline">
                <input name="customerPhone" type="text" class="input-style" maxlength="50"
                       placeholder="精确查找">
            </div>
        </div>
        <div class="layui-inline">
            <label>预计开启时间：</label>
            <div class="layui-inline">
                <input type="text" name="expectOpenDateStart" placeholder="开始时间" class="Wdate input-style" id="d4311"
                       onFocus="var d4312=$dp.$('d4312'); WdatePicker({onpicked:function(){d4312.focus();}, maxDate:'#F{ $dp.$D(\'d4312\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
            <span>~</span>
            <div class="layui-inline">
                <input type="text" name="expectOpenDateEnd" placeholder="结束时间" class="Wdate input-style" id="d4312"
                       onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
        </div>
        <div class="layui-inline">
            <label>暂停时间：</label>
            <div class="layui-inline">
                <input type="text" name="suspendTimeStart" placeholder="开始时间" class="Wdate input-style" id="d4313"
                       onFocus="var d4312=$dp.$('d4314'); WdatePicker({onpicked:function(){d4312.focus();}, maxDate:'#F{ $dp.$D(\'d4314\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
            <span>~</span>
            <div class="layui-inline">
                <input type="text" name="suspendTimeEnd" placeholder="结束时间" class="Wdate input-style" id="d4314"
                       onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4313\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
        </div>
        <div class="layui-inline">
            <label>关键字：</label>
            <div class="layui-input-inline">
                <input name="keyWords" type="text" class="input-style" style="width: 200px;"
                       placeholder="客户名/订单编号/生产订单编号/企业名称"/>
            </div>
        </div>

        <div class="layui-inline">
            <button class="layui-btn layui-btn-mini layui-btn-normal" onclick="dataTableReload()">搜索</button>
            <button class="layui-btn layui-btn-mini layui-btn-primary" onclick="clearSearchKeys()">清空</button>
        </div>
    </div>
    <%--按钮操作--%>
    <div class="table-conter">
        <d:hasUrlAuth authCode="ZZSC_RESUME_SUSPEND">
        <a href="javascript:void(0)" class="layui-btn layui-btn-mini" btnauthCode="ZZSC_RESUME_SUSPEND"
           onclick="resumeHandler('myTable','')">恢复办理</a>
        </d:hasUrlAuth>
        <div class="fr other-span">
            <div class="fr">
                <span class="bgBlueGreen">合同超期</span>
                <span class="bgRed">订单超期</span>
                <span class="bgBlue">节点超期</span>
            </div>
        </div>
    </div>
    <%--列表展示--%>
    <div class="table-body">
        <table id="myTable" class="cell-border crm-table columnsHidden dataTable">
            <colgroup>
                <col width="20">
                <col width="50">
            </colgroup>
        </table>
    </div>
</div>

<c:import url="/WEB-INF/jsp/footer.jsp"/>
<script type="text/javascript"
        src="${basePath}/static/js/zzsc/production/sc_common.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/zzsc/production/sc_divisionUser.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/zzsc/production/sc_business.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/choose.extend.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/zzsc/inprocess/inprocess_list.js?v=${version}"></script>
<script type="text/javascript" src="${basePath}/static/js/zzsc/common/call_common.js?v=${version}"></script>
<script type="text/javascript">
    var table = null, paras = null;

    $(document).ready(function () {
        //根据code加载下拉项
        $("select[code]").loadSelectOptions();
        //业务类型
        Plug.plug_in("post", "${basePath}/zzsc/common/tree_book_list.do?code=BUS_YT_ZZ&&type=2&&level=2", "#business_typeCode", '选择业态', '', true, 'BUS_YT_ZZ', '', '');
        //初始化dataTable列表
        table = $('#myTable').dataTableExtend({
            "ajax": {
                "url": "/zzsc/suspended_order/query.do",
                "type": "post"
            },
            "fnServerParams": function (aoData) {
                paras = $('.titleSearch').serializeJson();
                aoData = $.extend(aoData, paras);
                return aoData;
            },
            "scrollX": "true",//是否开启横项滚动
            "fixedColumns": {//锁定列，只有开启scrollX时才生效
                "leftColumns": 3,//左侧锁定2列
                "rightColumns": 1//右侧锁定1列
            },
            "aoColumns": [
                {
                    "orderable": false,
                    "data": "id",
                    "render": function (data, type, full, meta) {
                        return '<input type="checkbox"  name="ids" class="checkchild"  value="' + data + '" />';
                    }
                }
                , {
                    "title": "序号",
                    "orderable": false,
                    "render": function (data, type, full, meta) {
                        return meta.row + 1;
                    }
                },
                {
                    "title": "订单来源",
                    "orderable": false,
                    "data": "signOrgName"
                },
                {
                    "title": "订单编号",
                    "orderable": false,
                    "data": "orderNo",
                    "render": function (data, type, full, meta) {
                        return ('<a href=\'javascript:void(0)\' ti  onclick="openBusinessDetail(\'' + full.orderNo + '\',\'' + full.orderId + '\')" /><span class="layui-table-link">' + data + '</span></a>&nbsp;');
                    }
                },
                {
                    "title": "生产订单编号",
                    "orderable": false,
                    "data": "scProductOrderNo",
                    "render": function (data, type, row) {
                        {
                            return '<a href="javascript:;"  class="layui-table-link" onclick="openOrderInfoDetail(\'' + row.scProductOrderNo + '\',\'' + row.id + '\')" /><p>' + data + '</p></a>';
                        }
                    }
                }, {
                    "title": "客户",
                    "orderable": false,
                    "data": "customerName",
                    "render": function (d, type, r) {
                        return d + '<p>' + r.customerPhone + '</p>';
                    }
                }, {
                    "title": "当前已完成节点",
                    "orderable": false,
                    "data": "latestEndNodeName"
                }, {
                    "title": "业务类型",
                    "orderable": false,
                    "data": "businessProductName"
                }, {
                    "title": "产品类型",
                    "orderable": false,
                    "data": "productName"
                }, {
                    "title": "销售订单备注",
                    "orderable": false,
                    "data": "orderRemark",
                    "render": function (data, type, full, meta) {
                        if(data){
                            return  '<div class="line2" style="min-width: 120px" title="'+data+'">'+data+'</div> ';
                        }else{
                            return '';
                        }
                    }
                }, {
                    "title": "暂停时间",
                    "orderable": true,
                    "data": "suspendTime"
                }, {
                    "title": "预计开启时间",
                    "orderable": true,
                    "data": "expectOpenDate"
                },{//最新备注时间
                    "title": "最新备注",
                    "orderable": true,
                    "data": "lastRemarkTime",
                    "render": function (d, type, r) {
                        (d==null)&&(d='');
                        (r.lastRemark==null)&&(r.lastRemark='');
                        (r.lastUser==null)&&(r.lastUser='');
                        return '<div class="line2" style="min-width: 120px" title="'+r.lastRemark+'">'+r.lastRemark+'</div> '
                            + '<p>' + r.lastUser + '</p>'+ '<p>' + d + '</p>';
                    }
                },
                {
                    "title": "签单人",
                    "orderable": false,
                    "data": "signUserName"
                },
                {
                    "title": "签单部门",
                    "orderable": false,
                    "data": "signUserOrgName"
                }, {
                    "title": "流程人员",
                    "orderable": false,
                    "data": "flowUserName"
                },
                {
                    "title": "流程部门",
                    "orderable": false,
                    "data": "flowUserOrgName"
                },{
                    "title": "生产负责人",
                    "orderable": false,
                    "data": "productUserName",
                    "render": function (data, type, full, meta) {
                        if(data) {
                            return full.productUserName+'<p>'+full.productUserOrgName+'</p>';
                        }else{
                            return '';
                        }
                    }
                },{
                    "title": "企业名称",
                    "data": "companyName",
                    "orderable": false,
                    "render": function (data, type, full, meta) {
                        (data==null)&&(data='');
                        return '<div class="line2" style="min-width: 50px" title="'+data+'">'+data+'</div> ';
                    }
                }, {
                    "title": "操作",
                    "orderable": false,
                    "data": "id",
                    "render": function (d, type, r, meta) {
                        var result = "";
                        result += '<a href=\'javascript:void(0)\' ti  onclick="callPhoneByProduction(\'' + r.id + '\')" /><span style="color: #0066ff"; font-weight: bold ">打电话</a>&nbsp;&nbsp;&nbsp;';
                        <d:hasUrlAuth authCode="ZZSC_GENERAL_RESUME_SUSPEND">
                        result += '<a href=\'javascript:void(0)\' onclick="resumeHandler(\'' + "" + '\',\'' + r.id + '\')" /><span style="color: #0066ff; font-weight: bold " ">恢复办理</a>&nbsp;&nbsp;&nbsp;';//恢复办理
                        </d:hasUrlAuth>
                        result += '<a href=\'javascript:void(0)\' class="layui-table-link" onclick="remarkLayer(\'' + r.id + '\')" /><span style="color: #0066ff; font-weight: bold " ">备注</a>&nbsp;&nbsp;&nbsp;';
                        result += '<a href=\'javascript:void(0)\' ti  onclick="queryQGJ(\'' + r.id + '\')" /><span class="layui-table-link" style="font-weight: bold ">查询企管家</a>';
                        return result;
                    }
                }],
            "columnDefs": [{
                targets: [0],
                createdCell: function (td, cellData, rowData, row, col) {
                    var nodestatus = rowData.nodeTimeStatus;
                    var orderstatus = rowData.orderTimeStatus;
                    if ("OVERDUE_STATE2" == rowData.contractTimeStatus) {
                        $(td).parent().addClass("bgBlueGreen");
                        return;
                    }
                    if ("OVERDUE_STATE2" == orderstatus) {
                        $(td).parent().addClass("bgRed");
                        return;
                    }
                    if ("OVERDUE_STATE2" == nodestatus) {
                        $(td).parent().addClass("bgBlue");
                        return;
                    }
                }
            },
                {
                    targets: ["_all"], "defaultContent": ""
                }
            ]
        });

    });

    /**
     * 刷新表格
     */
    function refreshDataTable() {
        $('#myTable').dataTableExtend("reloadFalse");
    }

    /**
     * 恢复办理
     */
    function resumeHandler(tableid, id) {

        if (null != tableid && "" != tableid) {
            var data = $('#' + tableid).dataTableExtend('getCheck');
            if (data.length > 1) {
                DGG.Warning('只能选择一个订单！');
                return;
            }
            if (data.length == 0) {
                DGG.Warning('请选择一个订单！');
                return;
            }
            var id = data[0].id;
            DGG.loading();
            $.post(sysInfo.basePath + "/zzsc/suspended_order/layer_resume_suspend.html", {subOrderId: id}, function (data) {
                dgg.Open({
                    title: '恢复办理',
                    content: data,
                    area: '550px',
                    btn: ["恢复办理", "取消"],
                    success:function(){
                        areaLength($('#content'),500)
                    },
                    yes: function () {
                        doResumeOrder();
                    }
                });
            }, 'html');
        } else {
            $.post(sysInfo.basePath + "/zzsc/suspended_order/layer_resume_suspend.html", {subOrderId: id}, function (data) {
                dgg.Open({
                    title: '恢复办理',
                    content: data,
                    area: '30%',
                    btn: ["恢复办理", "取消"],
                    yes: function () {
                        doResumeOrder();
                    }
                });
            }, 'html');
        }
    }

    function export_data() {
        export_table('/zz/suspendedOrder/poi.do', paras);
    }


</script>
</body>

</html>
